package com.act.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import com.act.dao.IDepartDao;
import com.act.domain.Depart;
import com.act.dto.PagerDTO;
import com.act.service.api.IDepartService;
import com.act.vo.PagerVo;

@Service
public class DepartServiceImpl implements IDepartService{
	
	@Resource
	private IDepartDao departDao;

	@Override
	public void add(Depart depart) {
		departDao.add(depart);	
	}

	@Override
	public void update(Depart depart) {
		departDao.update(depart);
	}

	@Override
	public void delete(int id) {
		departDao.delete(id);	
	}

	@Override
	public PagerVo<Map> getAll(@Param("pagerDTO")PagerDTO pagerDTO) {
		int startIndex = pagerDTO.getStartIndex();
		int endIndex = pagerDTO.getEndIndex();
		int totalCounts = departDao.getCounts();
		List<Map> list = departDao.getAll(startIndex, endIndex);
		PagerVo<Map> pagerVo = new PagerVo<>(pagerDTO.getPageIndex(),pagerDTO.getPageSize(),totalCounts,list);

		return pagerVo;
	}

	@Override
	public Depart getById(@Param("id")int id) {
		return departDao.getById(id);
	}

	@Override
	public List<Depart> getAllList() {
		return departDao.getAllList();
	}

	

}
